package com.study.service.impl;

import com.study.dao.AwardInfoDAO;
import com.study.dao.impl.AwardInfoDAOImpl;
import com.study.dto.AwardDto;
import com.study.dto.MedalSearchDto;
import com.study.dto.PageDto;
import com.study.service.MedalSearchService;

import java.util.List;

/**
 * @PackgeName: com.study.service.impl
 * @ClassName: MedalSearchServiceImpl
 * @Author: 严志祥
 * Date: 2022-05-14 14:42
 * project name: web_project_medal
 * @Version:
 * @Description:
 */
public class MedalSearchServiceImpl implements MedalSearchService {
    private AwardInfoDAO dao = new AwardInfoDAOImpl();
    @Override
    public List<AwardDto> list(MedalSearchDto medalSearchDto) {
       try{
           return dao.selectSearch(medalSearchDto);
       }catch (Exception e){
           throw new RuntimeException("获取奖牌列表失败",e);
       }
    }

    @Override
    public PageDto<AwardDto> page(MedalSearchDto medalSearchDto) {
       try{
           PageDto<AwardDto> p = new PageDto<>(dao.countSearch(medalSearchDto),medalSearchDto.getCurrent(),medalSearchDto.getMaxRecord());
           medalSearchDto.setCurrent(p.getCurrent());
           p.setList(dao.selectSearch(medalSearchDto));
           return p;
       }catch (Exception e){
           throw new RuntimeException("获取奖牌分页失败",e);
       }
    }
}
